package com.ywgt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ywgt.pojo.Ad;
import com.ywgt.mapper.AdMapper;
import com.ywgt.service.AdService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 广告表 服务实现类
 * </p>
 *
 * @author yiping
 * @since 2021-03-13
 */
@Service
public class AdServiceImpl extends ServiceImpl<AdMapper, Ad> implements AdService {

    @Override
    public Page<Ad> getAds(String name, String content, int page, int limit, String sort, String order) {
        PageHelper.startPage(page,limit);
        return baseMapper.selectAds(name,content,sort,order);
    }

    @Override
    public List<Ad> getIndex() {
        LambdaQueryWrapper<Ad> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(Ad::getPosition,1);
        wrapper.eq(Ad::getDeleted,0);
        wrapper.eq(Ad::getEnabled,1);
        return this.list(wrapper);
    }
}
